home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / asmutil / asm_n_z.zip / RESOURCE.DOC < prev    next >
Text File  |  1986-01-28  |  26KB  |  772 lines

  1.         RESOURCE
  2.  
  3.     A disassembler for 8080 programs
  4.     by Ward Christensen
  5.  
  6.     CP/M U.G. 1/80
  7.  
  8. Suggestions?  Call me eve's at (312) 849-6279
  9.         ----------------
  10. RESOURCE commands are inconsistent at best. - RESOURCE is a 
  11. kludge based on years of disassembler experience and hacking, 
  12. and was never "planned" - just coded sitting at a tube, and
  13. modified over 2 years before being contributed to the CP/M UG.
  14.  
  15. For example, to kill a symbol: k.label   but to kill a 
  16. control value: caddr,k and to kill a comment: ;addr,
  17. but RESOURCE does the job like no other I have seen.
  18.         ----------------
  19. N-O-T-E: Pardon the editorial, but I feel hardware without
  20. good software is useless to 99% of us.  Most good software
  21. has to be paid for.  I strongly support the legitimate purchase
  22. of licensed software.  I do not regularly use any programs
  23. which I have not purchased.  (Yes, I do occasionally "try"
  24. one, but then buy it if I plan on using it).  I have been
  25. asked by software businesses to NOT distribute RESOURCE -
  26. because of it's ability to produce good .asm source quickly.
  27. But, there are so many disassemblers out, why not a good, 
  28. conversational one?   Please use it in the spirit in which it 
  29. was contributed: to enlarge your understanding of the micro-
  30. computer world around you, and to allow you to customize 
  31. programs which you legitimately own, for your own use.
  32.  
  33.     "Semper non rippus offus"
  34. ----
  35. NOTE: any command taking a hex address (Dnnnn, etc)
  36. may take a value in the form .label but arithmetic
  37. may not be performed.  (i.e. d.start is ok, but d.start+8 not)
  38.         ----------------
  39.     Overall structure of RESOURCE:  It is a .COM file,
  40. which runs at 100H.  It goes thru 1700 or so, then the stack.
  41. At 1800 is a 512 entry table for control commands.  Each is
  42. 3 bytes long, and controls the format of the re-sourced list,
  43. i.e. is it DB, DS, DW, instructions, etc.
  44.     At 1E00 is the start of the symbol table.  It has no
  45. defined length as such.  If it is not used, it occupies only
  46. 2 bytes.
  47.     If you want to re-source something which is in memory,
  48. such as a PROM, a program previously loaded in high memory,
  49. "CP/M itself", or whatever, you can just do so.
  50.     However, typically you want to disassemble a program
  51. which runs at 100H, which is were RESOURCE runs.   Bob
  52. Van Valzah would have solved that by making resource
  53. relocatable and moving itself up under BDOS.  I wasn't that
  54. industrious.
  55.     Instead, RESOURCE uses the concept of an "invisible"
  56. OFFSET.  After all, what do you care where it is as long
  57. as it LOOKS like it's at 100h?
  58.     So, you set an offset.  O2F00 sets it to 2F00 Hex.
  59. Reading a .COM file (RFOO.COM) causes it to come into 3000 on.
  60. If you say D100 or L100 it dumps or lists what LOOKS like your
  61. program.  Internally, RESOURCE is adding the offset to the
  62. D and L addresses.
  63.     What should you set the offset to?  Well, that depends
  64. upon how many symbols you will use.  O1F00 will load the
  65. program at 2000, thus allowing only 1E00-1FFF for symbols,
  66. i.e. 512 bytes or about 50-60 labels.  If you didn't leave
  67. enough space, then used B to build a default symbol table,
  68. the table could run into and clobber your .com file!  (easy
  69. recovery, however: just change the offset to being higher,
  70. and read in the .COM file again)  Each entry takes 3 bytes
  71. + the symbol length, and if you like 7 byte labels like I
  72. do, that means 10 bytes/label.  An offset of 2F00 should
  73. be adequate.
  74.     If you want to put comments into the disassembled
  75. program, you will have to designate an area to Use for the
  76. comments.  The U command (e.g. U4000) specifies what area
  77. is to be used.
  78.     Before issuing the O (offset) command, do:
  79.     L5 7
  80. which will show the JMP to BDOS, which is the highest memory
  81. you may use.  (Note if you have, for example, an empty 4K
  82. memory board in high memory, you can Use THAT for comments).
  83.     Let's take an example:  You have an 8K file, FOO.COM
  84. which you want to disassemble.  It will have about 300 labels.
  85. 300 x 10 is 3000, or call it 4K (what's a K unless your
  86. tight).  The symbol table starts at 1E00.  4K more is 2E00.
  87. Let's load the .COM at 2E00, so since it normally starts
  88. at 100H, the offset is 2D00.  O2D00 is the command.
  89. We then RFOO.COM to read it in.  It says 4E00 2100 which
  90. means it came into actual memory to 4E00, but 2100 if we
  91. are talking with respect to loading at 100.
  92.     Thus, we could set our comments table up after
  93. the .COM program - say at 5000:  U5000
  94.     The ? command shows the memory utilization for
  95. control, symbol, and comments entries.  (no, I never put
  96. in anything to keep track of the .COM - you'll just have
  97. to do that yourself).
  98.     If you ever want to dump real memory, you'll have
  99. to reset the offset to 0: O0  but then set it back.
  100. If you are not sure what it is, typing O will tell the
  101. current offset.
  102.  
  103.     Hoo, boy!  Hope this kludge of documentation
  104. is enough to get you going - hmmm, better give you
  105. some of the gotcha's I've discovered...
  106.  
  107.         ---- WATCH FOR ----
  108.  
  109. *    Symbols overflowing into the .COM.
  110.     (Use ? command to see how full symbol table is)
  111.  
  112. *    Control entries overflowing into .SYM (altho I
  113.     can't believe anyone will have a program with
  114.     more than 512 control entries!!!)
  115.  
  116. *    Comments overflowing into BDOS (ug!!)
  117.  
  118. *    Using an offset which is not in free memory
  119.     and overlaying BDOS or whatever.
  120.  
  121. *    The B(uild) command gobbling up too much when building
  122.     a DB:  "B" will take a DB 'GOBBELDY GOOK' followed
  123.     by LXI H,FOO and take the LXI as a '!' (21H) so
  124.     you'll have to manually stick a new "I" control
  125.     entry in at the address of the LXI.  You might
  126.     also delete the incorrect "I" entry which RESOURCE
  127.     stuck in (typically at the second byte of the LXI)
  128.  
  129. *    Trying to dump real memory without setting the
  130.     offset back to 0.  (then forgetting to set it back
  131.     to its proper value)
  132.  
  133. *    Forgetting how big the .COM file you are disassembling
  134.     was.
  135.  
  136. *    Using RESOURCE to rip off software (yes, I know, you
  137.     heard that before, but only 3 in 100 needed to be 
  138.     told, and 2 in 100 needs to be told again, and 1 in
  139.     100 doesn't give a rat's fuzzy behind anyway!!)
  140.  
  141. *    Forgetting to take checkpoints when disassembling
  142.     large files.  You may even want to rotate the names
  143.     under which things are saved:
  144.  
  145.     STEMP1.SYM
  146.     STEMP1.CTL
  147.     STEMP1.DOC
  148.  
  149. *    Missing a label:  Suppose you have a control entry
  150.     for a DW, resulting in:
  151.     
  152.     DFLT:        ;172C
  153.         DW    100H
  154.  
  155.     but somewhere in the program, the following exists:
  156.  
  157.         LDA     172DH
  158.  
  159.     Even if you did a B and have a label L172D, it won't
  160.     show up since it's in the middle of a DW.  Instead,
  161.     do this:
  162.  
  163.     K.l172d        kill the old label
  164.     e172d,.dflt+1    put in the new label as a displacement
  165.             off the beginning.
  166.  
  167. *    improperly disassembling DW's (see previous item).
  168.     You might be tempted to make DFLT a DB so that
  169.  
  170.     DFLT:        ;172C
  171.         DB    0
  172.     L172D:        ;172D
  173.         DB    1
  174.  
  175.     Note that while this disassembles and reassembles
  176.     properly, it is not "as correct" as the technique
  177.     used in the previous item.
  178.  
  179. *    Having the "B" command overlay your "E" control entry.
  180.     What?  Well, "B"uild is pretty dumb.  If he finds 8
  181.     DB type characters in a row, he fires off a DB from
  182.     then on until he runs out of those characters.  Suppose
  183.     your program was 200 long (ended at 3FF), and you
  184.     had zeroed (aha!  Nice DB candidates) memory there
  185.     (there meaning at your offset address + whatever).
  186.  
  187.     Then you QB100,400 and viola!!  RESOURCE overlaid
  188.     your "E" control with a "B".  
  189.         ----------------
  190.  
  191.     RESOURCE is relatively complete.  (well, actually,
  192.     the phrase "rampant featureitis" has been "mentioned").
  193.     ...But there's always another day, and another K...
  194.  
  195.         SO... Here's my "wish list"
  196.  
  197.     ..it might save you telling me YOU think such-and-such
  198.     would be nice...
  199.  
  200. *    Targets of LHLD, SHLD should automatically be flagged
  201.     as type DW in the control table.  Ditto LDA and STA
  202.     as DB or as second half of DW.  Ditto targets of LXI
  203.     as DB (?).
  204.  
  205. *        E5C,.FCB
  206.     followed by
  207.         E6C,.FCB+
  208.     should automatically calculate the appropriate
  209.     displacement, and put it in the symbol table.
  210.  
  211. *    The comments facility should be enhanced to allow
  212.     total SUBSTITUTION of entire line(s) of